﻿/*  
    Copyright (C) <2007-2013>  <Kay Diefenthal>

    DD.UI.MediaCenter is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DD.UI.MediaCenter is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DD.UI.MediaCenter.  If not, see <http://www.gnu.org/licenses/>.
*/

using System.Collections.Generic;
using DD.UI.MediaCenter.Views;
using Microsoft.MediaCenter;
using Microsoft.MediaCenter.Hosting;

namespace DD.UI.MediaCenter.ViewModels
{
    public class GuideViewModel
    {
        #region Private Fields
        
        private readonly AddInHost _host;
        private readonly HistoryOrientedPageSession _session;

        #endregion

        #region Constructor

        public GuideViewModel(HistoryOrientedPageSession session, AddInHost host)
        {
            _session = session;
            _host = host;
        }

        #endregion

        #region Properties

        public MediaCenterEnvironment MediaCenterEnvironment
        {
            get
            {
                if (_host == null)
                {
                    return null;
                }
                return _host.MediaCenterEnvironment;
            }
        }

        #endregion

        #region Private Methods

        private GuideView CreateGuideView()
        {
            var view = new GuideView();
            return view;
        }

        #endregion

        #region Public Methods

        public void GoToGuideView()
        {
            var uiProperties = new Dictionary<string, object>();
            uiProperties["GuideView"] = CreateGuideView();
            _session.GoToPage("resx://DD.UI.MediaCenter/DD.UI.MediaCenter.Resources/GuideView", uiProperties);
        }
        #endregion
    }
}
